In [1]:
%pylab inline
In [2]:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import os.path as op
from pprint import pprint as pp
import scipy.stats
import seaborn as sns
In [3]:
datapath = "~/teigen_data/output_rows.csv"
In [4]:
plotkw ={
"figsize": [9, 6],
"fontsize": 14,
}
plot_title_size = 40
plot_linewidth = 3
plot_boxprops = {
"linewidth": plot_linewidth
}
boxplotkw = {
"figsize": [9, 6],
"fontsize": 14,
"boxprops": plot_boxprops,
"medianprops": plot_boxprops,
"whiskerprops": plot_boxprops,
"capprops": plot_boxprops,
}
In [5]:
available_radius_methods = [
"inscribed", "circumscribed",
"average",
"cylinder volume",
"cylinder volume + sphere error",
"cylinder volume + sphere error + man",
"cylinder volume + sphere error + join error",
"cylinder surface",
"cylinder surface + sphere error",
"cylinder surface + sphere error + join error",
"cylinder surface + sphere error + join error man",
"best",
]
In [6]:
%run evaltools.ipynb
In [7]:
df = pd.read_csv(op.expanduser(datapath))
pp(df.keys())
# df
In [8]:
#pd.to_datetime(str(datetime.datetime.now()))
In [9]:
# pd.to_datetime(df[step2_datetime_key]) > pd.to_datetime("2017-07-05")
In [10]:
df =read_data(datapath)
In [11]:
# df = pd.read_csv(op.expanduser(datapath))
# df["surface error [mm^2]"] = df["numeric surface [mm^2]"] - df["surface [mm^2]"]
# df["surface error [%]"] = df["surface error [mm^2]"] / df["surface [mm^2]"] * 100
# df["volume error [mm^3]"] = df["numeric volume [mm^3]"] - df["volume [mm^3]"]
# df["volume error [%]"] = df["volume error [mm^3]"] / df["volume [mm^3]"] * 100
# df["measurement_resolution"] = df["postprocessing measurement_resolution"]
# df["length_distribution_mean"] = df["generators Unconnected tubes length_distribution_mean"]
In [12]:
dfs = df[
df[note_key] == "resolution sphere"
# df["generators Unconnected cylinders radius_distribution_mean"] == 5
]
dfsp = dfs[["surface error [%]", "volume error [%]", "measurement_resolution"]].sort_values(
"measurement_resolution")
if len(dfsp) > 0:
dfsp.plot(x="measurement_resolution", **plotkw)
dfsp
Out[12]:
In [13]:
#sns.factorplot("measurement_resolution", "surface error [%]", data=dfs)#.set(ylim=(0, 1))
In [14]:
sns.lmplot("measurement_resolution", "surface error [%]", data=dfs)#.set(ylim=(0, 1))
Out[14]:
In [15]:
dfs = df[
df[note_key] == "resolution tube"
# df["generators Unconnected cylinders radius_distribution_mean"] == 5
]
dfsp = dfs[["surface error [%]", "volume error [%]", "measurement_resolution"]].sort_values(
"measurement_resolution")
if len(dfsp) > 0:
dfsp.plot( x="measurement_resolution", **plotkw)
# dfsp
In [16]:
# df = pd.read_csv(op.expanduser(datapath))
# df["surface error [mm^2]"] = np.abs(df["numeric surface [mm^2]"] - df["surface [mm^2]"])
# df["surface error [%]"] = df["surface error [mm^2]"] / df["surface [mm^2]"] * 100
# df["volume error [mm^3]"] = np.abs(df["numeric volume [mm^3]"] - df["volume [mm^3]"])
# df["volume error [%]"] = df["volume error [mm^3]"] / df["volume [mm^3]"] * 100
# df["measurement_resolution"] = df["postprocessing measurement_resolution"]
dfs = df[
df[note_key] == "tube length"
# df["generators Unconnected cylinders radius_distribution_mean"] == 5
]
dfsp = dfs[["surface error [%]", "volume error [%]", "length_distribution_mean"]].sort_values(
"length_distribution_mean")
if len(dfsp) > 0:
dfsp.plot( x="measurement_resolution", **plotkw)
In [17]:
import seaborn as sns
In [18]:
pd.__path__
Out[18]:
In [19]:
pd.__version__
Out[19]:
In [20]:
## element_number = 10,
np.unique(df[note_key])
Out[20]:
In [21]:
display("<b>ahoj<b>")
In [22]:
evaluate_based_on_note(df, "compensation method 1 sphere ")
In [23]:
evaluate_based_on_note(df, "compensation method 1 sphere " )
# for radius_method in ["inscribed", "circumscribed", "cylinder surface", "cylinder volume", "average", "cylinder volume + sphere compensation"]:
# dfs = df[
# df[note_key] == "compensation method 1 sphere " + radius_method
# # df["generators Unconnected cylinders radius_distribution_mean"] == 5
# ]
#print dfs.keys()
#display(dfs[["surface [mm^2]", "numeric surface [mm^2]"]])
# show_error(dfs, radius_method=radius_method, plotkw=plotkw)
In [24]:
for radius_method in available_radius_methods:
dfs = df[
df[note_key] == "compensation method 1 tube " + radius_method
# df["generators Unconnected cylinders radius_distribution_mean"] == 5
]
show_error(dfs, radius_method=radius_method)
# dfplot(dfs, plotkw, radius_method)
In [25]:
for radius_method in available_radius_methods:
dfs = df[
df[note_key] == "compensation method N tube " + radius_method
# df["generators Unconnected cylinders radius_distribution_mean"] == 5
]
dfsp = show_error(dfs, radius_method=radius_method)
In [26]:
# for radius_method in ["cylinder volume + sphere compensation"]:
for radius_method in available_radius_methods:
dfs = df[
df[note_key] == "compensation method 5 tubes " + radius_method
]
dfsp = show_error(dfs)
In [27]:
for radius_method in ["inscribed", "circumscribed", "cylinder surface",
"cylinder volume", "average", "cylinder volume + sphere compensation"]:
dfs = df[
df[note_key] == "compensation method " + radius_method
# df["generators Unconnected cylinders radius_distribution_mean"] == 5
]
show_error(dfs, radius_method=radius_method)
# dfplot(dfs, plotkw, radius_method)
In [28]:
# for radius_method in ["cylinder volume + sphere compensation"]:
for radius_method in available_radius_methods:
dfs = df[
df[note_key] == "mix " + radius_method
]
dfsp = show_error(dfs, radius_method=radius_method)
In [29]:
evaluate_based_on_note(df, "mix 2 ")
In [30]:
# for radius_method in ["cylinder volume + sphere compensation"]:
for radius_method in available_radius_methods:
dfs = df[
df[note_key] == "mix 2 " + radius_method
]
dfsp = show_error(dfs, radius_method=radius_method, plotkw=plotkw)
In [31]:
dfs[["volume [mm^3]"]]
Out[31]:
In [32]:
### Kontrolní výpočet objemu
In [33]:
v_sphere = (4.0/3.0) * np.pi * 20.0**3
v_sphere
Out[33]:
In [34]:
v_cylinder = np.pi*20.0**2 * 2.6696777
v_cylinder
Out[34]:
In [35]:
v_cylinder + v_sphere
Out[35]:
In [36]:
# df = pd.read_csv(op.expanduser(datapath))
# df["surface error [mm^2]"] = df["numeric surface [mm^2]"] - df["surface [mm^2]"]
# df["surface error [%]"] = df["surface error [mm^2]"] / df["surface [mm^2]"] * 100
# df["volume error [mm^3]"] = df["numeric volume [mm^3]"] - df["volume [mm^3]"]
# df["volume error [%]"] = df["volume error [mm^3]"] / df["volume [mm^3]"] * 100
# df["measurement_resolution"] = df["postprocessing measurement_resolution"]
# df["element_number"] = df["generators Unconnected tubes element_number"]
# df["length_distribution_mean"] = df["generators Unconnected tubes radius_distribution_mean"]
# df["radius_distribution_mean"] = df["generators Unconnected tubes length_distribution_mean"]
dfs = df[
df[note_key] == "compensation method 5 tubes " + "best"
]
dfsp = dfs[["volume [mm^3]", "numeric volume [mm^3]", "surface [mm^2]", "numeric surface [mm^2]", "surface error [%]", "volume error [%]"]]
dfsp
Out[36]:
In [37]:
if len(dfsp) > 0:
axp = dfsp[["surface [mm^2]", "numeric surface [mm^2]"]].plot(kind="box", **plotkw)
In [ ]:
In [38]:
if len(dfsp) > 0:
axp = dfsp[["volume [mm^3]", "numeric volume [mm^3]"]].plot(kind="box", **plotkw)
In [39]:
if len(dfsp) > 0:
axp = dfsp[["surface error [%]", "volume error [%]"]].plot(kind="box", **plotkw)
In [ ]:
In [40]:
# for radius_method in ["cylinder volume + sphere compensation"]:
for radius_method in available_radius_methods:
# ["cylinder surface", "cylinder volume", "cylinder volume + sphere compensation", "best"]:
dfs = df[
df[note_key] == "compensation method 5 tubes " + radius_method
]
show_error(dfs, radius_method=radius_method)
dfs
# dfplot(dfs, plotkw, radius_method
In [41]:
nsu = dfsp["numeric surface [mm^2]"]
su = dfsp["surface [mm^2]"]
nsux = np.ones([len(nsu)])
sux = np.zeros([len(su)])
y = np.concatenate([nsu, su])
x = np.concatenate([nsux,sux])
#plot(, np.concatenate([nsux,sux]))
plt.plot(x, y)
Out[41]:
In [42]:
y.shape
Out[42]:
In [43]:
x.shape
Out[43]:
In [44]:
dfsp.describe()
Out[44]:
In [45]:
# for radius_method in ["cylinder volume + sphere compensation"]:
for radius_method in [
"inscribed",
# "circumscribed", "cylinder surface", "cylinder volume",
"average",
"cylinder volume + sphere compensation",
"best"]:
dfs = df[
df[note_key] == "fixed resolution " + radius_method
]
dfsp = dfs[["surface error [%]", "volume error [%]", "measurement_resolution"]].sort_values(
"measurement_resolution")
dfplot(dfs, plotkw, radius_method)
In [46]:
dfs
Out[46]:
In [47]:
# wilcoxon - čím větší, tím lepší
scipy.stats.wilcoxon(x=dfs["surface [mm^2]"], y=dfs["numeric surface [mm^2]"], correction=False, zero_method="pratt")
Out[47]:
In [48]:
scipy.stats.wilcoxon(dfs["surface error [%]"], correction=False, zero_method="pratt")
Out[48]:
In [49]:
# spearman čím menší, tím lepší
scipy.stats.spearmanr(dfs["surface [mm^2]"], dfs["numeric surface [mm^2]"])
Out[49]:
In [50]:
# wilcoxon - čím větší, tím lepší
scipy.stats.wilcoxon(x=dfs["volume [mm^3]"], y=dfs["numeric volume [mm^3]"], correction=False, zero_method="pratt")
Out[50]:
In [51]:
# spearman čím menší, tím lepší
scipy.stats.spearmanr(dfs["volume [mm^3]"], dfs["numeric volume [mm^3]"])
Out[51]:
In [52]:
resolution = 6
radius = 10
alpha = (2*np.pi) / (resolution)
radius_out = radius / np.cos(alpha/2)
radius_out
Out[52]:
In [53]:
np.cos(np.pi/2)
Out[53]:
In [54]:
np.concatenate([np.random.rand(10,10) * 120, np.ones([10,10])*99])
Out[54]: